package com.vogue.api.common.redisson;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * redisson 配置类
 */
@Configuration
public class RedissonConfig {
    @Value("${spring.redis.host}")
    private String host="127.0.0.1";
    @Value("${spring.redis.port}")
    private String port="6379";
    private String password="";

    @Bean
    public RedissonClient getRedisson(){

        Config config = new Config();
        config.useSingleServer().setDatabase(15).setAddress("redis://" + host + ":" + port);
        //添加主从配置
        //config.useMasterSlaveServers().setMasterAddress("").setPassword("").addSlaveAddress(new String[]{"",""});

        return Redisson.create(config);
    }

}
